package day10.collections.Queue;

/*
 * Author: JacksonCoder
 * FileName: LinkedListDemo
 * Version: 1.0.0
 * Date: 2025/4/17
 */

import java.util.LinkedList;

public class LinkedListDemo {

    public static void main(String[] args) {
        //双端队列
        LinkedList<String> list = new LinkedList<>();

        // 添加元素
        list.add("Java");
        list.addFirst("C++");
        list.addLast("Python");


        System.out.println(list);  // [C++, Java, Python]

        // 移除元素
        list.removeFirst();  // 移除 C++
        list.removeLast();   // 移除 Python

        // 按索引取值
        System.out.println(list.get(0));  // Java

        // 判空
        System.out.println(list.isEmpty());

        // 获取元素
        System.out.println(list.peekFirst());
        System.out.println(list.peekLast());
        System.out.println(list.peek());

        // 元素个数
        System.out.println("list size is: "+list.size());

        // 清空
        list.clear();

    }

}
